package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerCertification;
import com.shrcl.engineerprocess.domain.EngineerCertificationDocument;
import com.shrcl.engineerprocess.domain.impl.EngineerCertificationImpl;
import com.shrcl.engineerprocess.domain.proxy.EngineerCertificationDocumentProxy;
import edu.fudan.langlab.domain.document.IDocumentContainer;
import edu.fudan.langlab.domain.document.impl.DocumentStorageImpl;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("ENGINEERCERTIFICATIONDOCUMENT_TYPE")
public class EngineerCertificationDocumentImpl extends DocumentStorageImpl implements EngineerCertificationDocument {
  public EngineerCertificationDocumentImpl() {
    super();
  }
  
  public EngineerCertificationDocumentImpl(final EngineerCertification engineerCertification) {
    super();
    this.engineerCertification = engineerCertification;
  }
  
  @JoinColumn(name = "engineerCertification_id")
  @ManyToOne(targetEntity = EngineerCertificationImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private EngineerCertification engineerCertification;
  
  public EngineerCertification getEngineerCertification() {
    return this.engineerCertification;
  }
  
  public EngineerCertificationDocument setEngineerCertification(final EngineerCertification engineerCertification) {
    this.engineerCertification = engineerCertification;
    return this;			
    
  }
  
  public IDocumentContainer getContainer() {
    return this.engineerCertification;
  }
  
  public static EngineerCertificationDocument create(final EngineerCertification engineerCertification, final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.EngineerCertificationDocument engineerCertificationDocument = new com.shrcl.engineerprocess.domain.impl.EngineerCertificationDocumentImpl(
    	engineerCertification
    );
    objectFactory.create(engineerCertificationDocument);
    return engineerCertificationDocument;			
    
  }
  
  public static EngineerCertificationDocument createEngineerCertificationDocumentImpl(final EngineerCertification engineerCertification, final IObjectFactory objectFactory, final Procedure1<EngineerCertificationDocument> init) {
    com.shrcl.engineerprocess.domain.EngineerCertificationDocument engineerCertificationDocument = new com.shrcl.engineerprocess.domain.impl.EngineerCertificationDocumentImpl(
    	engineerCertification
    );
    objectFactory.create(engineerCertificationDocument);
    init.apply(engineerCertificationDocument);
    
    return engineerCertificationDocument;			
    
  }
  
  public EngineerCertificationDocumentProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.EngineerCertificationDocumentProxy proxy = new com.shrcl.engineerprocess.domain.proxy.EngineerCertificationDocumentProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
